package org.nextcore.ai.controller;

import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class QwenCoderController {
    
    private final OllamaChatModel chatModel;

    public QwenCoderController(OllamaChatModel chatModel) {
        this.chatModel = chatModel;
    }
    
    @GetMapping("/ai/generate")
    public String generate(@RequestParam(value = "message", defaultValue = "who are you?") String message) {
        String reply = this.chatModel.call(message);
        System.out.println("reply = " + reply);
        return reply;
    }
}
